package com.md.util;

import lombok.experimental.UtilityClass;
import org.springframework.util.ObjectUtils;

import java.util.Objects;

/**
 * @author 刘骄阳
 * 2023-12-20 17:14
 */
@UtilityClass
public class ObjectUtil {
  public static boolean isEmpty(final Object obj) {
    return ObjectUtils.isEmpty(obj);
  }

  public static boolean hasEmpty(final Object... objs) {
    if (ObjectUtils.isEmpty(objs)) {
      return true;
    }
    for (final Object obj : objs) {
      if (ObjectUtils.isEmpty(obj)) {
        return true;
      }
    }
    return false;
  }

  public static boolean isAllEmpty(final Object... objs) {
    if (isEmpty(objs)) {
      return true;
    }
    for (final Object obj : objs) {
      if (notEmpty(obj)) {
        return false;
      }
    }
    return true;
  }

  public static boolean notEmpty(final Object obj) {
    return !ObjectUtils.isEmpty(obj);
  }

  public static boolean equals(final Object obj, final Object obj2) {
    return Objects.equals(obj, obj2);
  }

  public static boolean hasEquals(final Object obj, final Object... objs) {
    for (final Object obj1 : objs) {
      if (Objects.equals(obj, obj1)) {
        return true;
      }
    }
    return false;
  }

  public static boolean unEquals(final Object obj, final Object obj2) {
    return !Objects.equals(obj, obj2);
  }

}
